/* ==========================================================================
   FlotteConvois - feuille de style (complète Bootstrap 5.3)
   ========================================================================== */
:root {
  --ink: #14213d;
  --ink-2: #1f3160;
  --accent: #fca311;
  --bs-primary: #2547a8;
  --bs-primary-rgb: 37, 71, 168;
  --bs-body-bg: #f4f6fb;
  --bs-border-radius: .6rem;
}
.btn-primary { --bs-btn-bg: #2547a8; --bs-btn-border-color: #2547a8; --bs-btn-hover-bg: #1d3a8c; --bs-btn-hover-border-color: #1d3a8c; --bs-btn-active-bg: #182f73; }
.btn-outline-primary { --bs-btn-color: #2547a8; --bs-btn-border-color: #2547a8; --bs-btn-hover-bg: #2547a8; --bs-btn-hover-border-color: #2547a8; --bs-btn-active-bg: #2547a8; }
.nav-pills { --bs-nav-pills-link-active-bg: #2547a8; }
a { color: #2547a8; }
.bg-ink { background: var(--ink) !important; }
.min-w-0 { min-width: 0; }

/* ---------- Barre latérale ---------- */
.sidebar { width: 250px; flex-shrink: 0; }
@media (min-width: 992px) {
  .sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; }
}
.sidebar .brand { border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar .brand i { color: var(--accent); }
.sidebar .nav-link { color: rgba(255,255,255,.75); border-radius: .5rem; padding: .55rem .75rem; margin-bottom: 2px; }
.sidebar .nav-link:hover { color: #fff; background: rgba(255,255,255,.06); }
.sidebar .nav-link.active { color: #fff; background: var(--ink-2); box-shadow: inset 3px 0 0 var(--accent); }
.sidebar .nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: rgba(255,255,255,.4); padding: 1rem .75rem .35rem; }

/* ---------- Cartes & KPI ---------- */
.card { border: 1px solid #e3e7f0; box-shadow: 0 1px 2px rgba(20,33,61,.04); }
.card-header { background: #fff; font-weight: 600; border-bottom-color: #eef1f6; }
.kpi { transition: transform .15s, box-shadow .15s; color: inherit; }
.kpi:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(20,33,61,.08); }
.kpi-icone { width: 48px; height: 48px; border-radius: .75rem; display: grid; place-items: center; font-size: 1.4rem; flex-shrink: 0; }
.kpi-valeur { font-size: 1.5rem; font-weight: 700; line-height: 1.1; color: var(--ink); }
.kpi-libelle { font-size: .82rem; color: #6c757d; }
.alertes-liste { max-height: 360px; overflow-y: auto; }

.vignette { width: 64px; height: 64px; object-fit: cover; border-radius: .4rem; border: 1px solid #dee2e6; }
.ligne-cliquable { cursor: pointer; }
.synthese dt { font-weight: 500; }
.synthese dd { margin-bottom: .35rem; }

/* Itinéraire */
.timeline-itineraire { position: relative; padding-left: .25rem; }
.timeline-itineraire .etape { display: flex; gap: .9rem; position: relative; padding-bottom: 1.1rem; }
.timeline-itineraire .etape:last-child { padding-bottom: 0; }
.timeline-itineraire .etape:not(:last-child)::before { content: ""; position: absolute; left: 6px; top: 16px; bottom: 0; border-left: 2px dashed #c5cde0; }
.timeline-itineraire .point { width: 14px; height: 14px; border-radius: 50%; border: 3px solid #2547a8; background: #fff; margin-top: 4px; flex-shrink: 0; }
.timeline-itineraire .point.fin { border-color: #dc3545; background: #dc3545; }

/* ---------- Tableaux → cartes sur mobile ---------- */
@media (max-width: 767.98px) {
  .table-cartes thead { display: none; }
  .table-cartes, .table-cartes tbody, .table-cartes tr, .table-cartes td, .table-cartes tfoot, .table-cartes th { display: block; width: 100%; }
  .table-cartes tr { border-bottom: 1px solid #e3e7f0; padding: .6rem .9rem; }
  .table-cartes td { border: 0; padding: .2rem 0; text-align: left !important; }
  .table-cartes td[data-label]::before { content: attr(data-label); display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: #8a94a6; }
  .table-cartes td:not([data-label]) { padding-top: .5rem; }
  .table-cartes td[colspan] { text-align: center !important; }
}

/* ---------- Connexion ---------- */
.login-page { background: radial-gradient(circle at 20% 20%, #2547a8 0, var(--ink) 55%); }
.login-card { max-width: 420px; border-radius: 1rem; }
.login-logo { width: 64px; height: 64px; border-radius: 1rem; background: var(--ink); color: var(--accent); display: grid; place-items: center; font-size: 2rem; }

/* ---------- Impression ---------- */
@media print {
  .sidebar, .navbar, .nav-tabs, .btn, form, .modal { display: none !important; }
  .tab-pane { display: block !important; opacity: 1 !important; }
  body { background: #fff; }
}

/* ==========================================================================
   PORTAIL CHAUFFEUR (mobile d'abord)
   ========================================================================== */
.portail { background: #eef1f7; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.portail-entete { background: linear-gradient(135deg, var(--ink), var(--ink-2)); color: #fff; padding: 1rem 1rem 2.4rem; padding-top: calc(1rem + env(safe-area-inset-top)); }
.portail-contenu { max-width: 560px; margin: -1.6rem auto 0; padding: 0 .85rem; }
.portail .card { border: 0; border-radius: 1rem; box-shadow: 0 2px 10px rgba(20,33,61,.06); }
.carte-vide { background: #fff; border-radius: 1rem; padding: 2rem 1.25rem; }
.carte-convoi .trajet .trait { border-left: 2px dashed #c5cde0; height: 18px; margin: 2px 0 2px 7px; }

.btn-action { background: #fff; border: 0; border-radius: 1rem; padding: .9rem .25rem; display: flex; flex-direction: column; align-items: center; gap: .25rem; box-shadow: 0 2px 10px rgba(20,33,61,.06); color: #2547a8; font-weight: 600; font-size: .85rem; }
.btn-action i { font-size: 1.6rem; }
.btn-action:active { transform: scale(.97); }
.btn-action-danger { color: #dc3545; }
.btn-action-success { color: #198754; }

.formulaire-mobile { background: #fff; border-radius: 1rem; padding: 1.1rem; box-shadow: 0 2px 10px rgba(20,33,61,.06); }
.formulaire-mobile .form-control, .formulaire-mobile .form-select { min-height: 46px; font-size: 16px; } /* 16px : évite le zoom iOS */
.montant-geant { font-size: 1.8rem !important; font-weight: 700; text-align: center; }

.grille-choix { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.grille-choix label { display: flex; flex-direction: column; align-items: center; gap: .2rem; padding: .6rem .2rem; font-size: .75rem; line-height: 1.1; border-radius: .75rem; }
.grille-choix label i { font-size: 1.35rem; }

.zone-signature { position: relative; border: 2px dashed #b8c2d8; border-radius: .75rem; background: #fafbfe; height: 200px; touch-action: none; }
.zone-signature canvas { width: 100%; height: 100%; display: block; border-radius: .75rem; }
.zone-signature .indice { position: absolute; inset: auto 0 .5rem 0; text-align: center; color: #b8c2d8; font-size: .8rem; pointer-events: none; }
.zone-signature.signee .indice { display: none; }

.apercu-photo { width: 72px; height: 72px; object-fit: cover; border-radius: .5rem; border: 1px solid #dee2e6; }

.portail-nav { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; display: flex; border-top: 1px solid #e3e7f0; padding-bottom: env(safe-area-inset-bottom); z-index: 1030; }
.portail-nav a { flex: 1; text-align: center; padding: .5rem 0 .45rem; color: #8a94a6; text-decoration: none; font-size: .7rem; display: flex; flex-direction: column; align-items: center; }
.portail-nav a i { font-size: 1.3rem; }
.portail-nav a.actif { color: #2547a8; font-weight: 600; }
.btn-envoi[disabled] { opacity: .7; }

/* ==========================================================================
   Assistant d'installation & logo
   ========================================================================== */
.install-page { background: radial-gradient(circle at 15% 10%, #2547a8 0, var(--ink) 60%) fixed; min-height: 100vh; }
.etapes-install { list-style: none; padding: 0; display: flex; justify-content: space-between; counter-reset: e; position: relative; }
.etapes-install::before { content: ""; position: absolute; top: 17px; left: 6%; right: 6%; height: 2px; background: rgba(255,255,255,.2); }
.etapes-install li { position: relative; flex: 1; text-align: center; color: rgba(255,255,255,.55); font-size: .78rem; }
.etapes-install li a { color: inherit; text-decoration: none; }
.etapes-install .pastille { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto .35rem; background: var(--ink); border: 2px solid rgba(255,255,255,.3); font-weight: 700; }
.etapes-install li.faite { color: #fff; }
.etapes-install li.faite .pastille { background: #198754; border-color: #198754; }
.etapes-install li.courante { color: #fff; font-weight: 600; }
.etapes-install li.courante .pastille { background: var(--accent); border-color: var(--accent); color: var(--ink); }
@media (max-width: 575.98px) { .etapes-install .libelle { display: none; } .etapes-install li.courante .libelle { display: block; } }
.recap { border: 1px solid #e3e7f0; border-radius: .75rem; padding: 1rem; background: #fafbfe; }
.apercu-logo { max-height: 48px; max-width: 120px; object-fit: contain; }
.logo-app { max-height: 34px; max-width: 150px; object-fit: contain; background: #fff; border-radius: .35rem; padding: 2px; }
.login-logo-img { max-height: 72px; max-width: 220px; object-fit: contain; }
.entete-impression { display: none; }
@media print {
  .entete-impression { display: flex !important; align-items: center; gap: 1rem; border-bottom: 2px solid #000; padding-bottom: .5rem; margin-bottom: 1rem; }
  .entete-impression img { max-height: 60px; }
}

/* Sauvegardes & mises à jour */
.voile-attente { position: fixed; inset: 0; background: rgba(20,33,61,.85); color: #fff; z-index: 2000; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 1rem; }
.notes-version { background: #f6f8fc; border-left: 3px solid var(--bs-primary); padding: .6rem .8rem; border-radius: .4rem; max-height: 220px; overflow: auto; }
